LuaRules in Map files (revisited) and 77b4

LuaRules in Map files (revisited) and 77b4

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

Post Reply
tinnut
Posts: 67
Joined: 09 Sep 2006, 08:17

LuaRules in Map files (revisited) and 77b4

Post by tinnut »

Hi Guys,

I've written a couple of LuaRules gadgets that I had intended to put into some maps I was working on - a teleporter, unit duplicator, and an "end game" scenario for a map where you have to hold 5 points to win. I'd just gotten them working under 76b1, with some graphical effects, only for them to stop working under 77b4.

Does anyone know of anything that changed that would have likely caused this and/or how I could work around it?

Under the svn build of Spring that came with the first release of PURE they still work (conversely the "WorldBuilder_GPL" map seemed to loose it's rain when I tried to run in under 77b4).

For now I guess I'll go back to looking through the Spring source code to see if I can find it myself.

Cheers.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: LuaRules in Map files (revisited) and 77b4

Post by Argh »

You don't get an error in Infolog, just a crash or non-functional Gadget?
tinnut
Posts: 67
Joined: 09 Sep 2006, 08:17

Re: LuaRules in Map files (revisited) and 77b4

Post by tinnut »

No errors in Infolog and Spring just runs fine without crashing.

My Initialize() call-in's both run for synced and unsynced, but my gadget:DrawWorld() call-in from my unsynced code isn't, and neither is my gadget:GameFrame(framenumber) from my synced code.

Even when I trim the code down to just the above call-ins and have them both do nothing other than a Spring.Echo so that I know that they've run, they still don't work.

I might try a clean install of Spring tonight and maybe look closer through the gadgets.lua code as well as the related c++.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: LuaRules in Map files (revisited) and 77b4

Post by Argh »

Hmm. Strange. gadget:DrawWorld() and gadget:GameFrame work just fine over here, although I should note that GameFrame is a sync operation, IIRC. If you'd care to post some code, I'll give it a whirl, see if I can pin it down.
tinnut
Posts: 67
Joined: 09 Sep 2006, 08:17

Re: LuaRules in Map files (revisited) and 77b4

Post by tinnut »

Thanks for your assistance Argh.

I did a clean install of 77b4 and found that the LuaRules in my map didn't work for the latest versions of BA or CA, but did work for an older mod that didn't have any LuaRules scripts in it, so it must be some conflict happening.

This gives me somewhere to start at least :)

I noticed from the log file that when I launch BA (or CA) with my map that one of the LUPS lua scripts fail, but when I use my map with its lua removed, there are no errors. I'll work back through the source and see what's run and when.
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Re: LuaRules in Map files (revisited) and 77b4

Post by KDR_11k »

You're supposed to use LuaGaia in a map, LuaRules is only for mods.
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: LuaRules in Map files (revisited) and 77b4

Post by Forboding Angel »

That's not entirely accurate KDR, but unfortunately I dunno how to explain why I would say that. Argh could prolly explain what I mean.
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: LuaRules in Map files (revisited) and 77b4

Post by jK »

KDR is right.

The only reason why LuaRules gadgets in maps get loaded is because the current VFS can't differ between mod and map files (they are just handled as zip/base files).

PS: also this example shows why -> the map LuaRules gadgets could crash the whole LuaRules enviroment or interact with the mod gadgets in way the modder didn't predict/want.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: LuaRules in Map files (revisited) and 77b4

Post by Argh »

All right... so we move them to the LuaGaia folder... is that all, or this there something else that needs to be done?
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: LuaRules in Map files (revisited) and 77b4

Post by jK »

you have to setup the gadgetHandler enviroment:
* copy main.lua,draw.lua,gadgets.lua etc. (or link the basecontent ones)
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: LuaRules in Map files (revisited) and 77b4

Post by Argh »

Cool, that basically means I'll just have to move the files, np.

BTW, kudos:
* fixed a bug in lua's fontHandler (it was the bug, which decreased the fps by >50% and was fixable by reloading luaui)
That was obnoxious :|
tinnut
Posts: 67
Joined: 09 Sep 2006, 08:17

Re: LuaRules in Map files (revisited) and 77b4

Post by tinnut »

Thanks for all the info guys. :-)

I'll convert my stuff over to LuaGaia although this will mean loosing some functionality due to the restrictions that LuaGaia has to work under compared to LuaRules. I had suspected that using LuaRules in a map was a bit of a hack, but it was worth trying at least.

Some of the stuff I was trying to do would have been quite unbalancing for some mods, but the worst offenders were mostly meant as a laugh.

Cheers.
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: LuaRules in Map files (revisited) and 77b4

Post by Beherith »

Would you please post said widgets? I have a map concept im working on, and I would like to build on your work
Post Reply

Return to “Lua Scripts”