Tutorial: Introduction to Lua scripting - Page 6 - ED Forums
 


Notices

Reply
 
Thread Tools Display Modes
Old 08-06-2015, 07:12 PM   #51
Sukhoi25
Member
 
Sukhoi25's Avatar
 
Join Date: Aug 2014
Location: Switzerland
Posts: 316
Default

Very useful guide. Thanks
__________________
Bye, SU

AMD FX-8350 @ 4.0 GHz, GIGABYTE (AMD) Radeon R9 280X Series @ 3GB Video, ATI Radeon / Realtek HD SoundCard, GIGABYTE FX-990GAUD Motherboard, Samsung 840EVO SSD @ 120GB, WD Caviar Blue @ 1TB
Sukhoi25 is offline   Reply With Quote
Old 09-30-2015, 08:10 PM   #52
ECV56_Polten
Junior Member
 
ECV56_Polten's Avatar
 
Join Date: Sep 2015
Location: CABA, Argentina
Posts: 22
Default

nick = "Yurgon"
msg = "you sir, are a GOD"

print (nick .. ", " .. msg)
env.info ("All hail the Yurgon... let him live foreva...(said with a James Earl Jones kind of voice)")
ECV56_Polten is offline   Reply With Quote
Old 12-16-2015, 07:46 AM   #53
richard008
Junior Member
 
Join Date: Dec 2015
Location: China
Posts: 50
Default

I put the code pasted directly into text text box, the result in dcs.log is:

00044.324 ERROR Trigger: can't execute trigger, err:"[string "?"]:1: bad argument #1 to 'loadstring' (string expected, got function)"

code:
version = "1.2.16"

-- Use two dashes to start a comment. This line will be ignored by the interpreter
opinion = "rocks" -- Oh, and comments can also follow after some code

print(sim .. " " .. version .. " " .. opinion)
end

I would like to ask what is the reason?
richard008 is offline   Reply With Quote
Old 12-16-2015, 08:26 AM   #54
richard008
Junior Member
 
Join Date: Dec 2015
Location: China
Posts: 50
Default

Quote:
Originally Posted by richard008 View Post
I put the code pasted directly into text text box, the result in dcs.log is:

00044.324 ERROR Trigger: can't execute trigger, err:"[string "?"]:1: bad argument #1 to 'loadstring' (string expected, got function)"

code:
version = "1.2.16"

-- Use two dashes to start a comment. This line will be ignored by the interpreter
opinion = "rocks" -- Oh, and comments can also follow after some code

print(sim .. " " .. version .. " " .. opinion)
end

I would like to ask what is the reason?
Is that because my lua version is 5.2.4?
richard008 is offline   Reply With Quote
Old 12-16-2015, 03:47 PM   #55
Yurgon
Campaign Testers
 
Yurgon's Avatar
 
Join Date: May 2010
Location: Germany
Posts: 6,452
Default

Probably a copy & paste error.

If you run it in the Live demo, do you get the same error?

AFAIK the code example is just fine and shouldn't break just because you run a certain version.
Attached Thumbnails
Click image for larger version

Name:	capture_20151216_001.png
Views:	158
Size:	95.8 KB
ID:	130413  
Yurgon is offline   Reply With Quote
Old 12-16-2015, 09:01 PM   #56
blaueente
Member
 
Join Date: Oct 2014
Location: Germany
Posts: 239
Default

@richard008 u forgot the first line...
blaueente is offline   Reply With Quote
Old 12-17-2015, 12:39 AM   #57
richard008
Junior Member
 
Join Date: Dec 2015
Location: China
Posts: 50
Default

Quote:
Originally Posted by blaueente View Post
@richard008 u forgot the first line...
Oh, I make a mistake When the paste is incomplete.

But only have code like "print("123456")" is also have the error ----Trigger: can't execute trigger, err:"[string "?"]:1: bad argument #1 to 'loadstring' (string expected, got function)".

Even I removed the do script action, this error persists, in DCS 1.2.16.

In DCS 1.5.0, this error occurs once every 10 seconds.

How to fix it?
richard008 is offline   Reply With Quote
Old 12-17-2015, 12:46 AM   #58
richard008
Junior Member
 
Join Date: Dec 2015
Location: China
Posts: 50
Default

Quote:
Originally Posted by Yurgon View Post
Probably a copy & paste error.

If you run it in the Live demo, do you get the same error?

AFAIK the code example is just fine and shouldn't break just because you run a certain version.
In my PC, lua script is run fine.


I removed the do script action, this error persists, in DCS 1.2.16.

In DCS 1.5.0, this error occurs once every 10 seconds.

So I think maybe it is a bug.

How to fix it?
richard008 is offline   Reply With Quote
Old 12-17-2015, 03:05 AM   #59
Yurgon
Campaign Testers
 
Yurgon's Avatar
 
Join Date: May 2010
Location: Germany
Posts: 6,452
Default

Quote:
Originally Posted by richard008 View Post
How to fix it?
I just ran a quick test in 1.5 and couldn't find anything wrong with the examples from the tutorial.

Can you upload your mission?
Yurgon is offline   Reply With Quote
Old 12-17-2015, 03:12 AM   #60
ajax
Member
 
ajax's Avatar
 
Join Date: Feb 2010
Posts: 474
Default

Trigger: can't execute trigger, err:"[string "?"]:1: bad argument #1 to 'loadstring' (string expected, got function)"

I've gotten that same error. It generally appears when an older mission is updated and saved in a newer version of DCS. I've never been able to fix it, but it doesn't seem to really hurt anything.
ajax is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT. The time now is 02:43 PM. vBulletin Skin by ForumMonkeys. Powered by vBulletin®.
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.